Repository navigation
fix(tmux): enable OSC 52 clipboard passthrough in nested tmux layers - #996
Conversation
Both genie.tmux.conf (inner/agent layer) and tui-tmux.conf (outer/TUI layer) used `set-clipboard on`, which causes tmux to consume OSC 52 sequences instead of forwarding them to the terminal emulator. This breaks clipboard sync for SSH users connecting through the TUI. Changes: - Switch both configs from `set-clipboard on` to `set-clipboard external` - Add `allow-passthrough on` and Ms terminal-override to genie.tmux.conf - Create osc52-copy.sh helper that writes OSC 52 directly to SSH PTY - Replace copy-selection-and-cancel with copy-pipe-and-cancel bindings that pipe through osc52-copy.sh in both configs - Update update.ts and setup.ts to install osc52-copy.sh to ~/.genie/ Closes #967
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Code Review
This pull request implements OSC 52 clipboard passthrough support for nested tmux sessions, which is particularly useful for clipboard operations over SSH. The changes include updating tmux configurations to use a new helper script, osc52-copy.sh, and ensuring this script is correctly installed and permissioned during setup and updates. Feedback on the helper script suggests piping data directly to base64 to avoid stripping trailing newlines and to improve memory efficiency for large buffers.
| buf=$(cat "$@") | ||
| encoded=$(printf '%s' "$buf" | base64 | tr -d '\n') |
There was a problem hiding this comment.
Capturing the input into a variable using buf=$(cat "$@") strips trailing newlines from the copied content, which is likely unintended for a clipboard helper. Additionally, for large clipboard buffers, it is more efficient to pipe the data directly to base64 to avoid unnecessary memory allocation in the shell.
| buf=$(cat "$@") | |
| encoded=$(printf '%s' "$buf" | base64 | tr -d '\n') | |
| encoded=$(cat "$@" | base64 | tr -d '\n') |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 22aa551590
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| const { resolve, dirname } = require('node:path') as typeof import('node:path'); | ||
| const genieHome = process.env.GENIE_HOME ?? join(homedir(), '.genie'); | ||
| const dest = join(genieHome, 'tmux.conf'); | ||
| if (existsSync(dest)) return; // already installed |
There was a problem hiding this comment.
Install OSC52 helper even when tmux.conf already exists
The early return on existing ~/.genie/tmux.conf prevents setup from installing ~/.genie/osc52-copy.sh, because the new helper-copy logic is placed after that return. This makes setup non-idempotent for the new clipboard path: if a user has a preexisting tmux config but is missing the helper script (for example after partial cleanup or a prior interrupted install), rerunning setup cannot repair clipboard copy bindings that now reference ~/.genie/osc52-copy.sh.
Useful? React with 👍 / 👎.
Summary
genie.tmux.confandtui-tmux.conffromset-clipboard ontoset-clipboard externalso tmux forwards OSC 52 sequences instead of consuming themallow-passthrough onandMsterminal-override to the inner (agent) tmux layer, which was missing bothosc52-copy.shhelper script that writes OSC 52 directly to the SSH PTY, bypassing nested tmux absorptioncopy-selection-and-cancelwithcopy-pipe-and-cancelbindings piping throughosc52-copy.shin both configsupdate.tsandsetup.tsto installosc52-copy.shto~/.genie/during setup/updateRoot Cause
set-clipboard ontells tmux to handle the clipboard internally (viaMscapability), which means it consumes OSC 52 sequences rather than passing them through to the terminal emulator. In a nested tmux setup (TUI outer layer + agent inner layer), this double-consumption completely prevents clipboard sync from reaching the user's terminal.Test plan
tmux-config.test.tscovering all 5 defectsbun run buildsucceedsbun run checkpasses (typecheck + lint + dead-code + tests)Closes #967